#ifndef _TSOCKET_H_
#define _TSOCKET_H_
#include "TNoCopyable.h"
#include "TLogger.h"
class TSocket : TNoCopyable
{
public:
    static bool EnvInit();
    static void EnvFree();
public:
    TSocket();
    TSocket(int sockfd);
    virtual ~TSocket();
    bool Validate();
    int fd()
    {
        return sockfd_;
    };

public:
    bool Listen(char* host, int port);
    TSocket* Accept();
    bool Connect(char* host, int port);
    int Send(char* buff, int len);
    int Recv(char* buff, int len);
    void Close();
public:
    bool SetNonBlock(bool block);
private:
    int sockfd_;
};

#endif

